package edu.towson.cis.cosc490.harvey.lab4;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;

public class AddNewItemActivity extends Activity {

	EditText editTextMessage;
	RadioButton highButton, medButton, lowButton;
	CheckBox checkBox;
	
	
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_item);
        editTextMessage=(EditText)findViewById(R.id.editText1);
        highButton = (RadioButton)findViewById(R.id.radio0);
        medButton = (RadioButton)findViewById(R.id.radio1);
        lowButton = (RadioButton)findViewById(R.id.radio2);
        checkBox = (CheckBox)findViewById(R.id.checkBox1);
        
    }
    
	public void addItem(View V)
	{
		// get the Entered  message
		String item = editTextMessage.getText().toString();
		Intent intentMessage = new Intent();
		
		
		//check which box is chosen
		if(checkBox.isChecked())
			intentMessage.putExtra("FINISHED", "TRUE");
		else if(medButton.isChecked())
			intentMessage.putExtra("FINISHED", "MED");
		else if(lowButton.isChecked())
			intentMessage.putExtra("FINISHED", "LOW");
		else if(highButton.isChecked())
			intentMessage.putExtra("FINISHED", "HIGH");
		else
			intentMessage.putExtra("FINISHED", "FALSE");
		
		//Debugging toast
		Toast.makeText(AddNewItemActivity.this, "Add new item: "+ item, Toast.LENGTH_LONG).show();
		
		// put the message in Intent
		intentMessage.putExtra("ITEM", item);

		setResult(2,intentMessage);
	
        finish();
	}
    
}
